<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1" xml:lang="en"><title id="gv141670">pg_locks</title><body><p>The <codeph>pg_locks</codeph> view provides access to information about the locks held by open
      transactions within Greenplum Database.</p><p><codeph>pg_locks</codeph> contains one row per active lockable object,
requested lock mode, and relevant transaction. Thus, the same lockable
object may appear many times if multiple transactions are holding or
waiting for locks on it. An object with no current locks
on it will not appear in the view at all. </p><p>There are several distinct types of lockable objects: whole relations
(such as tables), individual pages of relations, individual tuples of
relations, transaction IDs (both virtual and permanent IDs), and general database objects. Also, the right
to extend a relation is represented as a separate lockable object.</p><table id="gv141982"><title>pg_catalog.pg_locks</title><tgroup cols="4"><colspec colnum="1" colname="col1" colwidth="131pt"/><colspec colnum="2" colname="col2" colwidth="86pt"/><colspec colnum="3" colname="col3" colwidth="85pt"/><colspec colnum="4" colname="col4" colwidth="147pt"/><thead><row><entry colname="col1">column</entry><entry colname="col2">type</entry><entry colname="col3">references</entry><entry colname="col4">description</entry></row></thead><tbody><row><entry colname="col1"><codeph>locktype</codeph></entry><entry colname="col2">text</entry><entry colname="col3"/><entry colname="col4">Type of the lockable object: <codeph>relation</codeph>,
<codeph>extend</codeph>, <codeph>page</codeph>, <codeph>tuple</codeph>,
<codeph>transactionid</codeph>, <codeph>object</codeph>, <codeph>userlock</codeph>,
<codeph>resource queue</codeph>, or <codeph>advisory</codeph></entry></row><row><entry colname="col1"><codeph>database</codeph></entry><entry colname="col2">oid</entry><entry colname="col3">pg_database.oid</entry><entry colname="col4">OID of the database in which the object exists,
zero if the object is a shared object, or NULL if the object is a transaction
ID</entry></row><row><entry colname="col1"><codeph>relation</codeph></entry><entry colname="col2">oid</entry><entry colname="col3">pg_class.oid</entry><entry colname="col4">OID of the relation, or NULL if the object is
not a relation or part of a relation</entry></row><row><entry colname="col1"><codeph>page </codeph></entry><entry colname="col2">integer</entry><entry colname="col3"/><entry colname="col4">Page number within the relation, or NULL if
the object is not a tuple or relation page</entry></row><row><entry colname="col1"><codeph>tuple </codeph></entry><entry colname="col2">smallint</entry><entry colname="col3"/><entry colname="col4">Tuple number within the page, or NULL if the
object is not a tuple</entry></row><row><entry colname="col1"><codeph>virtualxid </codeph></entry><entry colname="col2">text</entry><entry colname="col3"/><entry colname="col4">Virtual ID of a transaction, or NULL if the object is
not a virtual transaction ID</entry></row><row><entry colname="col1"><codeph>transactionid </codeph></entry><entry colname="col2">xid</entry><entry colname="col3"/><entry colname="col4">ID of a transaction, or NULL if the object is
not a transaction ID</entry></row><row><entry colname="col1"><codeph>classid</codeph></entry><entry colname="col2">oid</entry><entry colname="col3">pg_class.oid</entry><entry colname="col4">OID of the system catalog containing the object,
or NULL if the object is not a general database object</entry></row><row><entry colname="col1"><codeph>objid </codeph></entry><entry colname="col2">oid</entry><entry colname="col3">any OID column</entry><entry colname="col4">OID of the object within its system catalog,
or NULL if the object is not a general database object</entry></row><row><entry colname="col1"><codeph>objsubid </codeph></entry><entry colname="col2">smallint</entry><entry colname="col3"/><entry colname="col4">For a table column, this is the column number
(the classid and objid refer to the table itself).
For all other object types, this column is zero. NULL if the object is
not a general database object</entry></row><row><entry colname="col1"><codeph>virtualtransaction</codeph></entry><entry colname="col2">text</entry><entry colname="col3"/><entry colname="col4">Virtual ID of the transaction that is holding or awaiting
this lock</entry></row><row><entry colname="col1"><codeph>pid</codeph></entry><entry colname="col2">integer</entry><entry colname="col3"/><entry colname="col4">Process ID of the server process holding or
awaiting this lock. NULL if the lock is held by a prepared transaction</entry></row><row><entry colname="col1"><codeph>mode</codeph></entry><entry colname="col2">text</entry><entry colname="col3"/><entry colname="col4">Name of the lock mode held or desired by this
process</entry></row><row><entry colname="col1"><codeph>granted</codeph></entry><entry colname="col2">boolean</entry><entry colname="col3"/><entry colname="col4">True if lock is held, false if lock is awaited.</entry></row><row><entry colname="col1"><codeph>fastpath</codeph></entry><entry colname="col2">boolean</entry><entry colname="col3"/><entry colname="col4">True if lock was taken via fastpath, false if lock is taken via main lock table.</entry></row><row><entry colname="col1"><codeph>mppsessionid</codeph></entry><entry colname="col2">integer</entry><entry colname="col3"/><entry colname="col4">The id of the client session associated with
this lock.</entry></row><row><entry colname="col1"><codeph>mppiswriter</codeph></entry><entry colname="col2">boolean</entry><entry colname="col3"/><entry colname="col4">Specifies whether the lock is held by a writer process.</entry></row><row><entry colname="col1"><codeph>gp_segment_id</codeph></entry><entry colname="col2">integer</entry><entry colname="col3"/><entry colname="col4">The Greenplum segment id (<codeph>dbid</codeph>)
              where the lock is held.</entry></row></tbody></tgroup></table></body></topic>
